<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <el-dialog :visible.sync="show" width="500px" :destroy-on-close="true" title="退货申请" v-loading="loading" :close-on-click-modal="false">

        <el-form size="small" label-position="left" label-width="110px">
            <el-form-item label="退货原因" label-position="left">
                {{ currentItem.returns_reason }}
            </el-form-item>
            <el-form-item label="是否同意申请" label-position="left">
                <el-radio-group v-model="currentItem.operation_status">
                    <el-radio :label="5">同意</el-radio>
                    <el-radio :label="6">拒绝</el-radio>
                </el-radio-group>
            </el-form-item>

            <el-form-item label="拒绝原因" v-if="currentItem.operation_status == 6" label-position="left">
                <el-input v-model="currentItem.reject_reason" type="textarea" :rows="12" :show-word-limit="true"
                    maxlength="300" />
            </el-form-item>

        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button size="mini" type="default" icon="el-icon-close" @click="cancleHandle">取消</el-button>
            <el-button size="mini" type="primary" icon="el-icon-check" @click="submitHandle">确定</el-button>
        </span>
    </el-dialog>
</template>

<script>

import {
    getScoreOrderById,
    addAdminRemark,
    returnOrder,
    delivery,
} from "@/api/score-order";
export default {
    name: "itemForm",
    components: {},

    EnumerationSelectorprops: {},
    data() {
        return {
            currentItem: {},
            show: false,
            loading: false,
        };
    },
    computed: {
        canSubmit: function () {
            var h = this.currentItem;
            if (h.desc && h.name && h.expired_at) {
                return true;
            }
            return false;
        },

    },
    watch: {},
    methods: {
        openDialog: function (item) {
            this.currentItem = item;

            this.show = true;
        },

        cancleHandle: function () {
            this.show = false;
            this.currentItem = {};
        },
        submitHandle: function () {
            var _this = this;
            this.loading = true;
            returnOrder(this.currentItem).then((resp) => {
                this.loading = false;
                if (resp.status == 0) {
                    _this.$message.success("保存成功");
                    _this.$emit("change", {});
                    this.show = false;
                    _this.loading = false;
                }
            });
        },
        orderStatus(i) {
            switch (i) {
                case 1:
                    return '待发货';
                case 2:
                    return '待收货';
                case 3:
                    return '已完成';
                // case 4:
                //     return '申请退货';
                // case 5:
                //     return '已退货';
                // case 6:
                //     return '驳回退货申请';
                default:
                    return '未知状态';
            }
        },
        orderStatusType(i) {
            switch (i) {
                case 1:
                    return 'warning';
                case 2:
                    return 'primary';
                case 3:
                    return 'success';
                case 4:
                    return 'danger';
                case 5:
                    return 'info';
                case 6:
                    return 'primary';
                default:
                    return 'info';
            }
        },

        submitDeliveryHandle() {
            var data = {
                id: this.currentItem.id,
                delivery_company: this.currentItem.delivery_company,
                delivery_no: this.currentItem.delivery_no,
                status: this.currentItem.status
            }
            this.$refs.deliveryForm.openDialog(data)
        },


        validate: function (data) {
            return true;
        },

    },
};
</script>

<style scoped>
.tips ul {
    padding: 0;
    margin: 0;
}

.tips {
    font-size: 12px;
    color: #999;
}

.show-more {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 10px;
}

.icon-uploader {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px;
    width: 100%;
    min-height: 100px;
    border: 2px dashed #f4f4f4;
}

.icon-uploader .el-upload {
    width: 100%;
    height: 100%;
}
</style>
